
package com.ukao.steward.pesenter.valetRunners;

import com.ukao.steward.base.BasePresenter;
import com.ukao.steward.bean.IncomeDetailbBean;
import com.ukao.steward.consts.Constant;
import com.ukao.steward.consts.SaveParams;
import com.ukao.steward.retrofit.ApiCallback;
import com.ukao.steward.util.CheckUtils;
import com.ukao.steward.util.L;
import com.ukao.steward.view.valetRunners.BalanceListView;

import java.util.HashMap;

import rx.Observable;

/**
 * Created by ukaodev on 2017/6/28.
 */

public class BalanceListPesenter extends BasePresenter<BalanceListView> {


    public BalanceListPesenter(BalanceListView view) {
        attachView(view);
    }





    public void incomeDetail(   int pageNum ,int pageSize,String  tradeType ,String  date,String  enterType ) {

        HashMap mHashMap = new HashMap<String, String>();
        mHashMap.put("pageNum",pageNum+"");
        if (!CheckUtils.isEmpty(tradeType)){  mHashMap.put("tradeType",tradeType);}
        if (!CheckUtils.isEmpty(date)){  mHashMap.put("date",date);}
        mHashMap.put("pageSize",pageSize+"");
        mHashMap.put("accessToken", SaveParams.getToken());
        L.i("mHashMap="+mHashMap.toString());
        Observable observable=null;
        if (enterType.equals("1")){
            observable=apiStores.incomeDetail(Constant.createParameter(mHashMap));
        }else{
            observable=apiStores.monthlist(Constant.createParameter(mHashMap));
        }

        addSubscription(observable,
                new ApiCallback<IncomeDetailbBean>() {
                    @Override
                    public void onSuccess(IncomeDetailbBean model) {

                        if (model.getHttpCode() == 200) {
                            mvpView.incomeSucceed(model.getData());


                        }else{

                            mvpView.showError(model.getMsg());
                        }

                    }


                    @Override
                    public void onFinish() {

                        mvpView.hideLoading();

                    }
                });

    }


}
